// pages/index/components/job/job.js
import {
    anit
} from '../../../../utils/util'

import user from '../../../../utils/user.js'
// const app = getApp()
Component({
    /**
   * 组件的属性列表
   */
    properties: {
        item: Object
    },
    observers: {
        'item': function (data) {
            this.setData({
                data: data
            })
        }
    },
    data: {
        showMoreStatus: false,
        morePosition: 0,
        isAdmin: false
    },
    ready() {
        this.setData({
            isAdmin: (user.isAdmin || user.isSuperAdmin),
        })
    },


    /**
     * 组件的方法列表
     */
    methods: {
        goProject(event) {
            if (anit(event)) {
                wx.navigateTo({
                    url: '/packagePay/pages/resident/resident?id=' + event.currentTarget.dataset.id,
                })
            }
        },
        hideMore() {
            this.setData({
                showMoreStatus: false
            })
        },
        // 显示更多
        showMore(event) {
            console.log(event)
            const list = [{
                text: '项目归档',
                key: '',
                icon: '/assets/img/file.png',
                bind: 'placeFile'
            }, ]
            if(user.isAdmin){
                list.push({
                    text: '修改名称',
                    key: '',
                    icon: '/assets/img/home/set.png',
                    bind: 'setName'
                })
            }
            this.setData({
                'moreList': list
            })
            this.setData({
                morePosition: event.touches[0].clientY + 6,
                showMoreStatus: true
            })
        },
        onSetName(){
            this.triggerEvent('setName',this.data.data.id)
        },
        onPlaceFile() {
            this.triggerEvent('placeFile',this.data.data.id)
        }
    }
})